import request from "@/utils/request";
import type {
  GetPermissionListResponse,
  SavePermissionParams,
} from "./model/permissionModel";
enum Api {
  getPermissionListUrl = `/admin/acl/permission/toAssign`,
  getAssignPermissionUrl = `/admin/acl/permission/doAssign`,
  getAssignPermissionListUrl = `/admin/acl/permission`,
  getSavePermissionListUrl = `/admin/acl/permission/save`,
}
// 获取权限管理列表
export const getPermissionListApi = (roleId: string) => {
  return request.get<any, GetPermissionListResponse>(
    Api.getPermissionListUrl + `/${roleId}`
  );
};
// 给角色分配权限
export const getAssignPermissionApi = (
  roleId: string,
  permissionId: string[]
) => {
  return request.post<any, null>(
    Api.getAssignPermissionUrl,
    {},
    {
      params: {
        roleId,
        permissionId: permissionId.join(","),
      },
    }
  );
};
// 获取菜单列表
export const getAssignPermissionListApi = () => {
  return request.get<any, GetPermissionListResponse>(
    Api.getAssignPermissionListUrl
  );
};
// 添加菜单
export const getSavePermissionListApi = (data: SavePermissionParams) => {
  return request.post<any, null>(Api.getSavePermissionListUrl, data);
};
